package cn.itlaobing.dao;

import com.alibaba.druid.pool.DruidDataSource;

import javax.sql.DataSource;

/**
 * Created by lhb on 2017/11/6.
 */
public class BaseDao {
    private static final String URL="jdbc:mysql://localhost:3308/orderformdb";
    private static final String USER="root";
    private static final String PWD="root";
    private static final String DRIVE="com.mysql.jdbc.Driver";
    private DataSource dataSource=null;
    /*
    * 创建连接池
    * */
    protected  DataSource getDataSource(){
        if (dataSource != null) {
            return dataSource;
        }
        DruidDataSource dataSource=new DruidDataSource();
        dataSource.setUrl(URL);
        dataSource.setUsername(USER);
        dataSource.setPassword(PWD);
        dataSource.setDriverClassName(DRIVE);
        this.dataSource=dataSource;
        return dataSource;
    }
}
